import Vue from 'vue';
import Vuex from 'vuex';

import getters from './getters';

import {
	enums,
} from '@/api/api.js';
Vue.use(Vuex);

export default new Vuex.Store({
	state: {
		enums: {},
		factuer: [], //厂商
		userInfo: {},
	},
	mutations: {
		SET_ENUMS: (state, enums) => {
			state.enums = enums
		},
	},
	actions: {
		enumsAll({
			commit
		}) {
			return new Promise((resolve, reject) => {
				enums().then((response) => {
					const {
						data
					} = response;
					commit('SET_ENUMS', data);
					resolve()
				}).catch(error => {
					reject(error)
				})
			})
		},
	},
	getters,
})
